package com.lancoo.znbkxx.teacher.ui.fragment.cognitiveAssessment

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.aibkTools.LancooMethod.addClickScale
import com.lancoo.znbkxx.teacher.aibkTestCoach.aibkTools.MyToast
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseFragment
import kotlinx.android.synthetic.main.fragment_cognitive_assessment.view.*


class CognitiveAssessmentFragment:KBaseFragment(), View.OnClickListener {

    companion object {
        private const val TITLE = "title"
        fun newInstance(title: String): CognitiveAssessmentFragment {
            val fragment = CognitiveAssessmentFragment()
            val bundle = Bundle()
            bundle.putString(TITLE, title)
            fragment.arguments = bundle
            return fragment
        }
    }

    private var rootView: View? = null
    private var list: MutableList<Fragment>? = null

    override fun createLayout(): Int {
        return R.layout.fragment_cognitive_assessment
    }

    override fun initView(view: View?) {
        rootView = view

        list = ArrayList()
        list!!.add(CaEstimateGradesFragment())
        list!!.add(CaCognitiveAverageScoreFragment())
        list!!.add(CaPaperAnsweredCountFragment())
        rootView!!.VpCognitiveAssessment.adapter = InviteFragmentAdapter(requireActivity().supportFragmentManager, list!!)
        rootView!!.VpCognitiveAssessment.setCurrentItem(1, false)
        rootView!!.VpCognitiveAssessment.offscreenPageLimit = 3 //记数从0开始!!! 设置预加载的个数

        rootView!!.VpCognitiveAssessment.setPageTransformer(false, DepthPageTransformer())
        rootView!!.VpCognitiveAssessment.pageMargin = -28

        rootView!!.RlCaCheckInfor.setOnClickListener(this)
        rootView!!.RlCaCheckInfor.addClickScale()
        rootView!!.RlCaGradeWay.setOnClickListener(this)
        rootView!!.RlCaGradeWay.addClickScale()


        val fragment = CognitiveInforListFragment()
        requireActivity().supportFragmentManager
                .beginTransaction()
                .add(R.id.FlCognitiveInforList, fragment)
                .commit()

    }

    override fun onClick(v: View?) {
        when(v?.id){
            R.id.RlCaCheckInfor -> {
                MyToast.showToast("查看详情")
            }
            R.id.RlCaGradeWay -> {
                MyToast.showToast("成绩走势")
            }
        }
    }
}